package com.emre.daoGenerator;

import com.emre.daoGenerator.dbSchema.SchemaInspector;
import com.vaadin.Application;
import com.vaadin.event.MouseEvents;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.web.context.ContextLoaderListener;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: emre
 * Date: 19.04.2011
 * Time: 20:52
 * To change this template use File | Settings | File Templates.
 */
@Configurable(preConstruction = true)
public class VaadinApplication extends Application {
    private Window window;

    @Override
    public void init() {
        window = new Window("DAO Code Generator");
        setMainWindow(window);

        final SchemaInspector ins = new SchemaInspector();

        final Label tableNamesLabel = new Label();
        window.addComponent(tableNamesLabel);

        Button showTableNamesButton = new Button("Show Table Names");
        showTableNamesButton.addListener(new Button.ClickListener(){
            @Override
            public void buttonClick(Button.ClickEvent event) {
//                List<String> tableNames = ins.queryForTableNames();
//                String result = "";
//
//                for(String s : tableNames)
//                {
//                    result += s + "\n";
//                }
//                tableNamesLabel.setValue(result);
                tableNamesLabel.setValue(ins.queryForTableCount() + " ");
            }
        });
        window.addComponent(showTableNamesButton);
    }
}
